//导入react-redux中的connect方法 来连接容器组件和UI组件
import { connect } from 'react-redux'

import React, { Component } from 'react'

//导入UI组件
// import BaseUI from '../components/Base'

//导入action
import { isAddAction } from '../Redux/action/Base_action'




// //导入store
// import store from '../../Redux/store'
// //导入Base_action方法 
// import {isAddAction,asynAddAction} from '../../Redux/Base_action'

 class Base extends Component {

  AdditionClick = () => {
    // store.dispatch({type:'inAdd',data:1})
      //  store.dispatch(isAddAction(10))
    
    this.props.jia(10)
  }
  //执行异步的操作
  asynClick = () => {
   //  store.dispatch(asynAddAction(2,1000))
    
    
  }

  render() {
    return (
        <div>
        {/* <h1>这里是react-redux的基{store.getState()}</h1> */}
        <h1>这里是react-redux的基{this.props.data}</h1>
            <button onClick={this.AdditionClick}>改变上面的数字</button>
            <button onClick={this.asynClick}>异步改变上面的数字</button>
      </div>
    )
  }
}



//
// function mapStateToProps(state) {
//     return {data:state}
// }

// function mapDispatchToProps(dispatch) {
//     return {
//         jia: (data) => {
//             dispatch(isAddAction(data))
//         }ß
//     }
// }


//连接 并暴露出去
// export default connect(mapStateToProps,mapDispatchToProps)(BaseUI)

export default connect(state => { return { data: state } },
{
jia:isAddAction    
}
)(Base)
